package com.py.custom.common.web.response;


import com.py.custom.common.web.enums.ResponseEnums;

import java.io.Serializable;

/**
 * description：统一返回对象，不提供set方法；所有接口返回结构
 *
 * @author pengyou
 * @version 1.0.0
 * @date 2021/10/17
 */
public class BaseResponse<T> implements Serializable {

    private final Integer code;

    private final String msg;

    private final String errorMsg;

    private final T data;

    public BaseResponse(ResponseEnums responseEnums, T data) {
        this.code = responseEnums.getCode();
        this.msg = responseEnums.getMsg();
        this.errorMsg = responseEnums.getErrorMsg();
        this.data = data;
    }

    public BaseResponse(ResponseEnums responseEnums, String errorMsg, T data) {
        this.code = responseEnums.getCode();
        this.msg = responseEnums.getMsg();
        this.errorMsg = errorMsg;
        this.data = data;
    }

    public Integer getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public String getErrorMsg() {
        return errorMsg;
    }

    public T getData() {
        return data;
    }
}
